package dashboard;

import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

import top.anka1.fxgui.RestaurantController;
import top.anka1.fxgui.ZooController;
import top.anka1.ims.*;
import top.anka1.ims.BankingTaskListGUI.BankingTaskListGUI;

import javax.swing.*;
/**
 * The DashBoardController class handles the actions for the dashboard GUI.
 * It provides methods to open different modules of the application, such as Zoo, Bank, Restaurant, and Shape.
 * @author Anka
 */
public class DashBoardController {
    @FXML
    public AnchorPane aboutPane;

    @FXML
    public void openZoo() {
        try {
            FXMLLoader fxmlLoader = new FXMLLoader(top.anka1.fxgui.ZooController.class.getResource("zoo-view.fxml"));
            Scene scene = new Scene(fxmlLoader.load());
            Stage stage = new Stage();
            ZooController zooController = fxmlLoader.getController();
            zooController.setStage2(stage);
            stage.setTitle("Zoo Management System");
            stage.setScene(scene);
            stage.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @FXML
    public void openBank() {
        SwingUtilities.invokeLater(() -> new BankingTaskListGUI());
    }
    @FXML
    public void openRestaurant() {
        try {
            FXMLLoader fxmlLoader = new FXMLLoader(top.anka1.fxgui.RestaurantController.class.getResource("restaurant-view.fxml"));
            Scene scene = new Scene(fxmlLoader.load());
            Stage stage = new Stage();
            RestaurantController restaurantController = fxmlLoader.getController();
            restaurantController.setStage2(stage);
            stage.setTitle("Restaurant Management System");
            stage.setScene(scene);
            stage.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @FXML
    public void openShape() {
        ShapeGUI shapeGUI = new ShapeGUI();
        shapeGUI.MainGUI();
    }
    @FXML
    public void endProgram() {
        Alert confirmationAlert = new Alert(Alert.AlertType.CONFIRMATION);
        confirmationAlert.setTitle("Exit Confirmation");
        confirmationAlert.setHeaderText("Are you sure you want to exit?");
        confirmationAlert.setContentText("Click OK to exit, or Cancel to return to the application.");
        confirmationAlert.showAndWait().ifPresent(response -> {
            if (response.equals(ButtonType.OK)) {
                System.exit(0);
            }
        });
    }
}
